{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('./dataset/Income1.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Education</th>\n",
       "      <th>Income</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>26.658839</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>10.401338</td>\n",
       "      <td>27.306435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>10.842809</td>\n",
       "      <td>22.132410</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>11.244147</td>\n",
       "      <td>21.169841</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>11.645485</td>\n",
       "      <td>15.192634</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>12.086957</td>\n",
       "      <td>26.398951</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>12.488294</td>\n",
       "      <td>17.435307</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>12.889632</td>\n",
       "      <td>25.507885</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>13.290970</td>\n",
       "      <td>36.884595</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>13.732441</td>\n",
       "      <td>39.666109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>14.133779</td>\n",
       "      <td>34.396281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>14.535117</td>\n",
       "      <td>41.497994</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>14.976589</td>\n",
       "      <td>44.981575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>15.377926</td>\n",
       "      <td>47.039595</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>15</td>\n",
       "      <td>15.779264</td>\n",
       "      <td>48.252578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>16.220736</td>\n",
       "      <td>57.034251</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>17</td>\n",
       "      <td>16.622074</td>\n",
       "      <td>51.490919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>18</td>\n",
       "      <td>17.023411</td>\n",
       "      <td>61.336621</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>19</td>\n",
       "      <td>17.464883</td>\n",
       "      <td>57.581988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>20</td>\n",
       "      <td>17.866221</td>\n",
       "      <td>68.553714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>21</td>\n",
       "      <td>18.267559</td>\n",
       "      <td>64.310925</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>22</td>\n",
       "      <td>18.709030</td>\n",
       "      <td>68.959009</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>23</td>\n",
       "      <td>19.110368</td>\n",
       "      <td>74.614639</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>24</td>\n",
       "      <td>19.511706</td>\n",
       "      <td>71.867195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>25</td>\n",
       "      <td>19.913043</td>\n",
       "      <td>76.098135</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>26</td>\n",
       "      <td>20.354515</td>\n",
       "      <td>75.775218</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>27</td>\n",
       "      <td>20.755853</td>\n",
       "      <td>72.486055</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>28</td>\n",
       "      <td>21.157191</td>\n",
       "      <td>77.355021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>29</td>\n",
       "      <td>21.598662</td>\n",
       "      <td>72.118790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>30</td>\n",
       "      <td>22.000000</td>\n",
       "      <td>80.260571</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Unnamed: 0  Education     Income\n",
       "0            1  10.000000  26.658839\n",
       "1            2  10.401338  27.306435\n",
       "2            3  10.842809  22.132410\n",
       "3            4  11.244147  21.169841\n",
       "4            5  11.645485  15.192634\n",
       "5            6  12.086957  26.398951\n",
       "6            7  12.488294  17.435307\n",
       "7            8  12.889632  25.507885\n",
       "8            9  13.290970  36.884595\n",
       "9           10  13.732441  39.666109\n",
       "10          11  14.133779  34.396281\n",
       "11          12  14.535117  41.497994\n",
       "12          13  14.976589  44.981575\n",
       "13          14  15.377926  47.039595\n",
       "14          15  15.779264  48.252578\n",
       "15          16  16.220736  57.034251\n",
       "16          17  16.622074  51.490919\n",
       "17          18  17.023411  61.336621\n",
       "18          19  17.464883  57.581988\n",
       "19          20  17.866221  68.553714\n",
       "20          21  18.267559  64.310925\n",
       "21          22  18.709030  68.959009\n",
       "22          23  19.110368  74.614639\n",
       "23          24  19.511706  71.867195\n",
       "24          25  19.913043  76.098135\n",
       "25          26  20.354515  75.775218\n",
       "26          27  20.755853  72.486055\n",
       "27          28  21.157191  77.355021\n",
       "28          29  21.598662  72.118790\n",
       "29          30  22.000000  80.260571"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Income')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly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fSZ7J9b8watG2S9DVJM7Pnvx24PPsr46zm923qez/SX31qtv82SX8l6W5JD0s6q2P/IFYrTvxWdT2jSj2/K+lI4FPAG4GzgAn7BEl6OY3mcudExKnAZdlDdwJnRsQC4HPA+yJiG/BJ4OMRMT8i7hj1dp8GrohGf/X7gKuaHjssIs6g0SnzKswScKnHqu6AUo+k+cAjEbE12/4ssHSC9zkHuDEiHgeIiJFe9scDn88agR0BPHKwN5H0QqA3Im7Pdg3SaIg2YqQx1wZgzgQxmU2KR/xWV+P1KnmW/T8XR2a3Guc1fwf8fUTMA/646fmT9XR2uw8PzCwRJ36roweBEyWdlG2/uemxbcBpAJJOo9FCGhqNvt4k6UXZY9Oy/S8EhrP7A8+9DU8Bx4z+xRHxA+DJpvr9W4HbRz/PLCUnfqu60TX+lRHxExqlnVuyk7vbm57/RWCapM00LkzyMEBEPAB8GLhd0j3ASNvcDwJfkHQH+7dj/jfgt0dO7o6KaYDGla7uBeYDf9G+wzWbmLtzmpnVjEf8ZmY148RvZlYzTvxmZjXjxG9mVjNO/GZmNePEb2ZWM078ZmY18/91fdtzIbA37gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(data.Education, data.Income)\n",
    "plt.xlabel('Education')\n",
    "plt.ylabel('Income')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from torch import nn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = nn.Linear(1, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Linear(in_features=1, out_features=1, bias=True)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "loss_fn = nn.MSELoss()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = torch.from_numpy(data.Education.values.reshape(-1, 1)).type(torch.FloatTensor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "Y = torch.from_numpy(data.Income.values.reshape(-1, 1)).type(torch.FloatTensor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "opt = torch.optim.SGD(model.parameters(), lr=0.0001)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "for epoch in range(5000):\n",
    "    for x, y in zip(X, Y):\n",
    "        y_pred = model(x)\n",
    "        loss = loss_fn(y, y_pred)\n",
    "        opt.zero_grad()\n",
    "        loss.backward()\n",
    "        opt.step()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Parameter containing:\n",
       "tensor([[4.9716]], requires_grad=True)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.weight"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Parameter containing:\n",
       "tensor([-28.3139], requires_grad=True)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.bias"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x266f4850b80>]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KG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BvwReyvz33yo9zoGcR87n9wFnVnqcg/g7OQX4e+AV4EXgykqPcxDn8ilgJ/BTgrnXT1Z6nCHO41MEN19/lvW++Ewa3/f9nEvk73uV0ouIpFSaplBERCSLAlxEJKUU4CIiKaUAFxFJKQW4iEhKKcBFRFJKAS4iklL/H5Vc0C2VgwowAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(data.Education, data.Income)\n",
    "plt.plot(X.numpy(), model(X).data.numpy(), c='r')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 分解写法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "w = torch.randn(1, requires_grad=True)\n",
    "b = torch.zeros(1, requires_grad=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "模型的公式： w@x + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "learning_rate = 0.0001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "for epoch in range(5000):\n",
    "    for x, y in zip(X, Y):\n",
    "        y_pred = torch.matmul(x, w) + b\n",
    "        loss = (y-y_pred).pow(2).sum()\n",
    "        if not w.grad is None:\n",
    "            w.grad.data.zero_()\n",
    "        if not b.grad is None:    \n",
    "            b.grad.data.zero_()\n",
    "        loss.backward()\n",
    "        with torch.no_grad():\n",
    "            w.data -= w.grad.data*learning_rate\n",
    "            b.data -= b.grad.data*learning_rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([4.9740], requires_grad=True)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([-28.3584], requires_grad=True)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x266f5872e20>]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAiJElEQVR4nO3debzWY/7H8deHLBnLQcskmgwtlkzlWGPGFKNhqImMscxhGs0Yk7JExVgnopAsQyPEYIRUIyQVxpKcFiVtP1I6pULZSuvn98d1n5xOZ7nvc7738j3n/Xw8etzLue9zPl+5333P9b0+12XujoiIxM922S5ARESqRgEuIhJTCnARkZhSgIuIxJQCXEQkpupk8ofVq1fPmzZtmskfKSISe1OnTv3c3euXfj6jAd60aVMKCwsz+SNFRGLPzBaV9byGUEREYkoBLiISUwpwEZGYUoCLiMSUAlxEJKYU4CIiMaUAFxGJKQW4iEg6rVgBvXrBV19F/q2TCnAzu8zMZpvZB2b2lJntbGZ7mdl4M1uQuN0z8upEROJqwwa4+242HNCMDffex5+63UG7ARMZNb0osh9RaYCbWWPgUiDf3Q8FtgfOBvoAE9y9GTAh8VhERCZOhDZtoFcvJjdoxskX3surBx5F0eq19B05K7IQT3YIpQ5Q18zqALsAS4FOwPDE14cDnSOpSEQkrhYtgq5doUMHWLOGq8+/mfPPvIGP9953y0vWbtjEwHHzIvlxlQa4uxcBg4DFwDLgK3d/B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YkvqvgLQV+kbjfHliQxVqSkvhtZxgwx93vLPGl2H3uyzuWtHzu3T3n/gBPAcuADYRg6AbsTbgKvSBxu1e266zGsfwf8CkwI/HngWzXWZXjKPX1T4B62a6zGn8nOwL/Bj4ApgHts11nNY7lOGAq8D5h7PXwbNeZxHEcR7j4OrPE5+KUOH7uKziWyD/3aqUXEYmpOA2hiIhICQpwEZGYUoCLiMSUAlxEJKYU4CIiMaUAFxGJKQW4iEhM/T9SENfGSke2kwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(data.Education, data.Income)\n",
    "plt.plot(X.numpy(), (torch.matmul(X, w) + b).data.numpy(), c='r')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "tch_gpu",
   "language": "python",
   "name": "tch2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
